home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Text / hdshowany.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.6 KB  |  117 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.    filename    : hdshowany.m
  35.    date created    :  9-feb-90
  36.    last updated    : 26-oct-90
  37.    author        : ross a jeynes
  38.    porter        : ken r fromm
  39.    purpose    : showany routine for generic driver.  This is the central text-setting
  40.                 routine.  Handles (font changes-temporarily removed), kerning,
  41.                 underline, superscript, etc.
  42. */
  43.  
  44. #import "hdshowany.h"
  45. #import "DrawingViewWraps.h"
  46.  
  47. #import <objc/Storage.h>
  48. #import <dpsclient/dpsclient.h>
  49. #import <dpsclient/wraps.h>
  50.  
  51. static void hd_showstr(int start, int end, ShowStruct *show, float spaceval, float trackval)
  52. {
  53.     if (start == end)
  54.         return;
  55.  
  56.     /*
  57.     *    Decide wether to use show, ashow, widthshow or awidthshow
  58.     */
  59.     if (spaceval == 0.0)
  60.     {
  61.         if (trackval == 0.0)
  62.              PSWShow((char *)((show->text)+start), (end-start));
  63.         else
  64.             PSWAshow(trackval, 0,  (char *)((show->text)+start), (end-start));
  65.     }
  66.     else
  67.     {
  68.         if (trackval == 0.0)
  69.             PSWWidthshow(spaceval, 0, 32, (char *)((show->text)+start), (end-start));
  70.         else
  71.              PSWAwidthshow(spaceval, 0, 32, trackval, 0, (char *)((show->text)+start), (end-start));
  72.     }
  73. }
  74.  
  75. void ShowAny(ShowStruct *show)
  76. {
  77.     int lastshow=0;            /* last "show" went from this point in show->text[] */
  78.  
  79.     /* indexes into ShowStruct arrays */
  80.  
  81.     int textptr            =0;            /* current character in show->text[] */
  82.     int prkernptr        =0;            /* pair kern */
  83.     int absmovptr        =0;            /* absolute moveto array index */
  84.     int spaceadjptr    =0;            /* space adjustment for justification */
  85.     int trackkernptr    =0;            /* track kern */
  86.  
  87.     float spaceval        =0.0;
  88.     float trackval        =0.0;
  89.  
  90.     while (textptr < show->textlen)
  91.     {
  92.         if (show->attr[textptr] == SA_NOATTR)
  93.         {
  94.             textptr++;
  95.             continue;
  96.         }
  97.  
  98.         if (lastshow != textptr)
  99.             hd_showstr(lastshow, textptr, show, spaceval, trackval);
  100.  
  101.         if (show->attr[textptr] & SA_ABSMOV)
  102.         {
  103.             PSmoveto(show->absmov[absmovptr].x, show->absmov[absmovptr].y);
  104.             absmovptr++;
  105.         }
  106.         if (show->attr[textptr] & SA_PRKERN)
  107.             PSrmoveto(show->prkern[prkernptr++], 0);
  108.         if (show->attr[textptr] & SA_TRACKADJ)
  109.             trackval = (show->trackkernlen ? show->trackkern[trackkernptr++] : 0.0);
  110.         if (show->attr[textptr] & SA_SPACEADJ)
  111.             spaceval = (show->spaceadjlen ? show->spaceadj[spaceadjptr++] : 0.0);
  112.  
  113.         lastshow = textptr++;  /* mark last show and increment show pointer */
  114.     }
  115.  
  116.     hd_showstr(lastshow, textptr, show, spaceval, trackval);
  117. }
  118.